package hibernate;

/**
 *
 * @author Igor Kovb
 */
public class UserRole extends DBEntity {

    //private int id;
    private String roleName;

    private UserRole(int DBid, String rN) {
        this.setId(DBid);
        roleName = rN;
    }

    UserRole() {
    }
    private final static UserRole USER = new UserRole(1, "User");
    private final static UserRole MANAGER = new UserRole(2, "Manager");
    private final static UserRole PRESIDENT = new UserRole(3, "President");
    private final static UserRole GUEST = new UserRole(4, "Guest");

    /**
     * @return the user role object
     */
    public static UserRole GET_USER_ROLE() {
        UserRole res = new UserRole();
        res.setId(USER.getId());
        res.setRoleName(USER.getRoleName());
        return res;
    }

    /**
     * @return the manager role object
     */
    public static UserRole GET_MANAGER_ROLE() {
        UserRole res = new UserRole();
        res.setId(MANAGER.getId());
        res.setRoleName(MANAGER.getRoleName());
        return res;
    }

    /**
     * @return the president role object
     */
    public static UserRole GET_PRESIDENT_ROLE() {
        UserRole res = new UserRole();
        res.setId(PRESIDENT.getId());
        res.setRoleName(PRESIDENT.getRoleName());
        return res;
    }

    /**
     * @return the guest role object
     */
    public static UserRole GET_GUEST_ROLE() {
        UserRole res = new UserRole();
        res.setId(GUEST.getId());
        res.setRoleName(GUEST.getRoleName());
        return res;
    }

    /**
     * The method to compare UserRole class objects
     * @param ur - the role to compare
     * @return 
     */
    public boolean equals(UserRole ur) {
        boolean res = false;
        if (this.getId() == ur.getId() && this.getRoleName().equals(ur.getRoleName())) {
            res = true;
        }
        return res;
    }

    @Override
    public boolean equals(Object o) {
        boolean res = false;
        if (o instanceof UserRole) {
            UserRole p = (UserRole) o;
            res = this.equals(p);
        }
        return res;
    }

    /**
     * @return the roleName
     */
    public String getRoleName() {
        return roleName;
    }

    /**
     * @param roleName the roleName to set
     */
    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }
}
